import Vue from 'vue'
import Router from 'vue-router'
import Login from '@/components/Login.vue'
import Index from '@/components/Index.vue'
import Welcome from '@/components/Welcome.vue'
import Reserve from '@/components/Reserve.vue'
import CarInfo from "../components/CarInfo";
import DriverInfo from '@/components/DriverInfo.vue'
import RegisterUser from "@/components/RegisterUser";
//解决router报错
const routerPush = Router.prototype.push
Router.prototype.push = function push (location) {
  return routerPush.call(this, location).catch(error => error)
}


Vue.use(Router)
export default new Router({
  //去掉请求地址的 # :history
  mode:'history',
  routes: [
    {
      path: '/',
      name: 'Login',
      component: Login
    },
    {
      path: '/index',
      name: 'Index',
      component: Index,
      children:[ //配置子路由
        {
          path:'',
          name:'Welcome',
          component:Welcome,
        },
        {
          path:'Reserve',
          name:'Reserve',
          component:Reserve,
        },
        {
          path:'carInfo',
          name:'CarInfo',
          component:CarInfo,
        },{
          path:'driverInfo',
          name:'DriverInfo',
          component:DriverInfo,
        },

      ]
    },
    {
      path:'/registerUser',
      name:'RegisterUser',
      component:RegisterUser,
    },
  ]
})
